import { reqGetHospitalShow } from '@/api/hospital/hospitalList'
import { GetHospitalShowResponse } from '@/api/hospital/model/hospitalList';
import { Badge, Button, Card, Descriptions } from 'antd'
import React, { useEffect, useState } from 'react'
import { useSearchParams } from 'react-router-dom'

export default function HospitalShow() {
  //获取地址栏 url 的 id 参数
  let [search] = useSearchParams();
  let id = search.get('id');
  //定义状态
  let [{ hospital, bookingRule }, setHospital] = useState<any>({});
  //组件挂载完毕
  useEffect(() => {
    let getHospital = async () => {
      let res = await reqGetHospitalShow(id as string);
      //更新状态
      setHospital(res);
    }
    getHospital();
  }, []);

  return (
    <Card>
      <Descriptions title="基本信息" bordered>
        <Descriptions.Item style={{ width: 150 }} label="医院名称">{hospital?.hosname}</Descriptions.Item>
        <Descriptions.Item label="医院Logo" span={2}>{
          hospital ? <img width="60" src={`data:image/png;base64, ${hospital?.logoData}`} /> : ''
        }</Descriptions.Item>
        <Descriptions.Item label="医院编码">{hospital?.hoscode}</Descriptions.Item>
        <Descriptions.Item label="医院地址" span={2}>{hospital?.param.fullAddress}</Descriptions.Item>

        <Descriptions.Item label="坐车路线" span={3}>
          {hospital?.route}
        </Descriptions.Item>
        <Descriptions.Item label="医院简介" span={3}>
          {hospital?.intro}
        </Descriptions.Item>
      </Descriptions>
      <div className="h-20"></div>
      <Descriptions title="预约规则信息" bordered>
        <Descriptions.Item label="预约周期">{bookingRule?.cycle}</Descriptions.Item>
        <Descriptions.Item label="放号时间" span={2}>{bookingRule?.releaseTime}</Descriptions.Item>
        <Descriptions.Item label="停挂时间">{bookingRule?.stopTime}</Descriptions.Item>
        <Descriptions.Item label="退号时间" span={2}>{bookingRule?.quitTime}</Descriptions.Item>

        <Descriptions.Item label="预约规则" span={3}>
          {bookingRule?.rule}
        </Descriptions.Item>
      </Descriptions>
      <div className="h-20"></div>
      <Button>返回</Button>
    </Card>
  )
}
